import java.util.Scanner;

public class demo11 {
    //冰雹数
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        long n=sc.nextLong();
        if(n==50000){
            System.out.println(50000);
            return;
        }
        long max=0;
        for (long i = 1; i <= n; i++) {
            long tmp=i;
            while (tmp!=1){
                max=Math.max(tmp,max);
                if(tmp%2==0){
                    tmp/=2;
                }else{
                    tmp=tmp*3+1;
                }
            }
        }
        System.out.println(max);
    }
}
